package com.dyna.config;

import org.flowable.engine.ProcessEngine;
import org.flowable.engine.ProcessEngineConfiguration;
import org.flowable.engine.impl.cfg.StandaloneProcessEngineConfiguration;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zhoucaiwang
 */
@Configuration
public class FlowableConfig {

    @Value("${spring.datasource.driver-class-name}")
    private String flowableDriver;
    @Value("${spring.flowable.url}")
    private String flowableUrl;
    @Value("${spring.datasource.username}")
    private String flowableUsername;
    @Value("${spring.datasource.password}")
    private String flowablePassword;

    @Bean
    public ProcessEngine getProcessEngine() {
        ProcessEngineConfiguration cfg = new StandaloneProcessEngineConfiguration()
                .setJdbcUrl(flowableUrl)
                .setJdbcUsername(flowableUsername)
                .setJdbcPassword(flowablePassword)
                .setJdbcDriver(flowableDriver)
                .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
        return cfg.buildProcessEngine();
    }

}
